import base from "@/utils/global.params.js";
let Mock = require("mockjs");
let Random = Mock.Random;

// 用户-注册-模拟接口
Mock.mock(base.baseUrl + "/user/regist", "post", (req, res) => {
    /*
    *获取到请求参数进行，判断,判断验证码是否匹配
    */
    if (JSON.parse(req.body).data.code == base.userRegist.code) {
        return {
            code: 200,
            msg: "注册成功",
            data: base.userToken,
        };
    } else {
        return {
            code: 1,
            msg: "注册失败",
            data: "",
        };
    }

});
// 用户-登陆-模拟接口
Mock.mock(base.baseUrl + "/user/login", "post", (req, res) => {
    /*
    *获取到请求参数进行，判断
    */
    if ((JSON.parse(req.body).data.tel == base.userLogin.tel) && (JSON.parse(req.body).data.psw == base.userLogin.psw)) {
        return {
            code: 200,
            msg: "登陆成功",
            data: base.userToken,
        };
    } else {
        return {
            code: 1,
            msg: "登陆失败",
            data: "",
        };
    }

});
// 用户-忘记密码-模拟接口
Mock.mock(base.baseUrl + "/user/forget", "post", (req, res) => {
    /*
    *获取到请求参数进行，判断
    */
    if (req.data == base.userForget) {
        return {
            code: 200,
            msg: "重置密码成功",
            data: base.userToken,
        };
    } else {
        return {
            code: 1,
            msg: "重置密码失败",
            data: "",
        };
    }

});
